$string = rtrim($string, ',');
phpCopy<?php $mystring = "This is a PHP program."; echo substr($mystring, 0, -1); ?>
echo substr('a,b,c,d,e,', 0, -1); # => 'a,b,c,d,e'